
import 'package:flutter/material.dart';
import 'package:sptapp/page/login/forget_pwd.dart';
import 'package:sptapp/page/login/login_code_page.dart';

import '../page/login/login_sec_page.dart';
import '../page/login/mail_register.dart';
import '../page/login/register.dart';
import '../page/min/add_device.dart';
import '../page/min/connect_device.dart';
import '../page/min/connect_us.dart';
import '../page/min/device_net_page.dart';
import '../page/min/min_about_page.dart';
import '../page/min/min_add_device_input.dart';
import '../page/min/min_add_device_success.dart';
import '../page/min/min_ai_guard_page.dart';
import '../page/min/min_change_avatar.dart';
import '../page/min/min_change_device_name.dart';
import '../page/min/min_choose_address.dart';
import '../page/min/min_choose_city_page.dart';
import '../page/min/min_device_net_info_page.dart';
import '../page/min/min_info_change_nickname.dart';
import '../page/min/min_info_page.dart';
import '../page/min/min_installer_info.dart';
import '../page/min/min_manage_access_page.dart';
import '../page/min/min_peoducts_page.dart';
import '../page/min/min_pwd_page.dart';
import '../page/min/min_security_change_email.dart';
import '../page/min/min_security_email_code.dart';
import '../page/min/min_set_language.dart';
import '../page/min/min_setting_page.dart';
import '../page/min/min_setting_security_page.dart';
import '../page/min/set_page.dart';
import '../page/monitor/device_control.dart';
import '../page/monitor/inverter_detail.dart';
import '../page/monitor/time_select.dart';
import '../page/test/season.dart';
import '../page/web_view/web_view.dart';
import '../widget/mobile_scan.dart';


class MyRoute {
  static GlobalKey<NavigatorState> navigatorKey = GlobalKey();
  // 配置路由
  Map routes = {
    'RegisterPage' : (context, {arguments}) => RegisterPage(),
    'ForgetPwd' : (context, {arguments}) => ForgetPwd(type: arguments,),
    'MinSetPage' : (context, {arguments}) => MinSetPage(),
    'AddDevicePage' : (context, {arguments}) => AddDevicePage(),
    'InverterDetailPage' : (context, {arguments}) => InverterDetailPage(),
    'ScanPage' : (context, {arguments}) => MobileScanPage(),
    'ConnectUsPage' : (context, {arguments}) => ConnectUsPage(),
    'ConnectDevicePage' : (context, {arguments}) => ConnectDevicePage(),

    'WebViewPage' : (context, {arguments}) => WebViewPage(arguments: arguments,),
    'MinInfoPage' : (context, {arguments}) => MinInfoPage(),
    'DeviceNetPage' : (context, {arguments}) => DeviceNetPage(),
    'MinInfoChangeNickname' : (context, {arguments}) => MinInfoChangeNickname(),
    'MinAddDeviceSuccess' : (context, {arguments}) => MinAddDeviceSuccess(sn: arguments,),
    'MinAddDeviceInput' : (context, {arguments}) => MinAddDeviceInput(deviceInfo: arguments,),
    'MailRegister' : (context, {arguments}) => MailRegister(isBanck: arguments,),
    'MinChangeDeviceName' : (context, {arguments}) => MinChangeDeviceName(device: arguments,),
    'DeviceControl' : (context, {arguments}) => DeviceControl(arguments: arguments,),
    'CupertinoPickerDemo' : (context, {arguments}) => CupertinoPickerDemo(),
    'LoginSecPage' : (context, {arguments}) => LoginSecPage(arguments: arguments,),
    'LoginCodePage' : (context, {arguments}) => LoginCodePage(arguments: arguments,),
    'MinAboutPage' : (context, {arguments}) => MinAboutPage(),
    'MinSettingPage' : (context, {arguments}) => MinSettingPage(),
    'MinChangeAvatar': (context, {arguments}) => MinChangeAvatar(),
    'MinSettingSecurityPage': (context, {arguments}) => MinSettingSecurityPage(),
    'MinSecurityChangeEmail' : (context, {arguments}) => MinSecurityChangeEmail(arguments: arguments,),
    'MinSecurityEmailCode' : (context, {arguments}) => MinSecurityEmailCode(arguments: arguments,),
    'MinPwdPage': (context, {arguments}) => MinPwdPage(arguments: arguments,),
    'MinManageAccessPage' : (context, {arguments}) => MinManageAccessPage(arguments: arguments,),
    'MinSetLanguagePage' : (context, {arguments}) => MinSetLanguagePage(),
    'MinAiGuardPage'  : (context, {arguments}) => MinAiGuardPage(),
    'MinDeviceNetInfoPage' : (context, {arguments}) => MinDeviceNetInfoPage(),
    'MinChooseAddressPage' : (context, {arguments}) => MinChooseAddressPage(arguments: arguments,),
    'MinPeoductsPage' : (context, {arguments}) => MinPeoductsPage(),

    'SeasonsScreen' : (context, {arguments}) => SeasonsPage(),
    'MinChooseCityPage' : (context, {arguments}) => MinChooseCityPage(arguments:arguments),
    'MinInstallerInfo' : (context, {arguments}) => MinInstallerInfo(status: arguments,),

  };

  Route onGenerateRoute(RouteSettings settings) {
    // 统一处理
    final String? name = settings.name;
    final Function pageContentBuilder = routes[name];
    if (pageContentBuilder != null) {
      if (settings.arguments != null) {
        final Route route = MaterialPageRoute(
            settings: RouteSettings(name: name, arguments: settings.arguments),
            builder: (context) =>
                pageContentBuilder(context, arguments: settings.arguments));
        return route;
      }else{
        final Route route = MaterialPageRoute(
            settings: RouteSettings(name: name, arguments: settings.arguments),
            builder: (context) =>
                pageContentBuilder(context,));
        return route;
      }
    }
    final Route route = MaterialPageRoute(
        settings: RouteSettings(name: name, arguments: settings.arguments),
        builder: (context) => pageContentBuilder(context));
    return route;
  }
}
